<template>
  <div>
    <el-form-item label-width="125px" label="表单联动效果">选择管理员后需要输入管理员验证码</el-form-item>
    <form-create :rule="rule" v-model:api="fApi" :option="options"/>
  </div>
</template>

<script setup>
import {ref, watch} from 'vue';

const flag = ref(false);
const fApi = ref(null);
const rule = ref([
  {
    type: 'select',
    field: 'user_role',
    title: '用户角色',
    options: [
      { value: 'admin', label: '管理员' },
      { value: 'user', label: '普通用户' }
    ],
    control: [
      {
        value: 'admin',
        rule: [
          { type: 'input', field: 'admin_code', title: '管理员验证码' }
        ]
      }
    ]
  }
]);
const options = ref({
  onSubmit: (formData) => {
    alert(JSON.stringify(formData))
  },
  resetBtn: true
});
</script>
